﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JScriptSuite.InteropServices;
using System.Runtime.Remoting;

namespace JScriptSuite.QA.Lib
{
    static class JResultItemUtility
    {
        internal static JResultItem Push(this JResultItem resultItem, params object[] items)
        {
            JArray ar = resultItem.Items;
            for (int i = 0; i < items.Length; i++)
            {
                ar.Push(items[i]);
            }

            return resultItem;
        }

        internal static JResultItem Push(this JResultItem resultItem, params JResultItem[] children)
        {
            for (int i = 0; i < children.Length; i++)
            {
                resultItem.Children.Push(children[i]);
            }

            return resultItem;
        }

        internal static object Unwrap(object source)
        {
            IObjectHandle objectHandle = source as IObjectHandle;
            return objectHandle != null ? objectHandle.Unwrap() : source;
        }

    }
}
